using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace EfeitosEspeciais02
{
  
    public class Game1 : Microsoft.Xna.Framework.Game
    {
        GraphicsDeviceManager graphics;
        SpriteBatch spriteBatch;

        Texture2D imagem;
        Vector2 posicaoXY;
        int persianaEfeito = 1;
        bool persianaEfeitoOn = false;


        public Game1()
        {
            graphics = new GraphicsDeviceManager(this);
            Content.RootDirectory = "Content";
        }


        protected override void Initialize()
        {

            IsMouseVisible = true;

            base.Initialize();
        }

        protected override void LoadContent()
        {          
            spriteBatch = new SpriteBatch(GraphicsDevice);

            imagem = Content.Load<Texture2D>("logoXNA");    
        }


        protected override void UnloadContent()
        {
           
        }


        protected override void Update(GameTime gameTime)
        {

            KeyboardState keyBoard = Keyboard.GetState();

            if (keyBoard.IsKeyDown(Keys.Space))
            {
                persianaEfeitoOn = true;
            }

            if (persianaEfeitoOn && persianaEfeito < 10)
            {
                persianaEfeito = ((int)(gameTime.TotalGameTime.TotalSeconds * 10) % 10) + 1;
            }
               

            base.Update(gameTime);
        }


        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);

            spriteBatch.Begin();

            if (persianaEfeito < 10)
            {
                for (int i = 0; i < imagem.Height; i += persianaEfeito)
                {
                    spriteBatch.Draw(imagem, new Rectangle((int)posicaoXY.X, (int)posicaoXY.Y + i, imagem.Width, 1), new Rectangle(0, i, imagem.Width, 1), Color.White);

                }

           }

            spriteBatch.End();

            base.Draw(gameTime);
        }
    }
}
